package com.ll.app.controller.jj;

import com.ll.app.api.jj.AddJJClassDTO;
import com.ll.app.api.jj.PageJJClassReqDTO;
import com.ll.base.dto.ApiResultDTO;
import com.ll.domain.jj.base.JJClassBaseService;
import com.taobao.api.ApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/jj/class")
@RequiredArgsConstructor
@Api(tags = "基金班级相关API")
public class JJClassController {

    private final JJClassBaseService jjClassBaseService;

    @ResponseBody
    @ApiOperation(value = "分页查询")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public ApiResultDTO page(@RequestBody @Validated PageJJClassReqDTO pageReq) throws ApiException {
        return ApiResultDTO.success(jjClassBaseService.page(pageReq));
    }

    @ResponseBody
    @ApiOperation(value = "创建班级")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ApiResultDTO add(@RequestBody @Validated AddJJClassDTO dto) throws ApiException {
        return ApiResultDTO.success(jjClassBaseService.add(dto));
    }

}


